package com.demo.juc.async;

import java.util.concurrent.*;

public class FutureTaskMain {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //Callable  有返回回调
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        FutureTask<String> futureTask = new FutureTask<>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                return "FutureTask test!";
            }
        });
        executorService.submit(futureTask);
        System.out.println(futureTask.get());
        executorService.shutdown();

    }
}
